#ifndef IMAGE_MANAGER_H_
#define IMAGE_MANAGER_H_

// INCLUDES //
#include "graphics/surface.h"
#include "graphics/screen.h"
#include <string>
#include <vector>
//////////////

using namespace std;

/// The replacement color for build up animations
#define COLOR_BUILD_REPLACE 			Color(255, 0, 207)

/// Number of resources
const int NUM_IMAGES = 80;
/// The image mappings
const int IMAGE_MAPPING[][4] = 
{
	{0,100,420,668}, 	// puzzle background
	{620,140,200,100},	// player background
	{420,100,40,40},	// blue gem
	{460,100,40,40},	// red gem
	{500,100,40,40},	// green gem
	{540,100,40,40},	// yellow gem
	{580,100,40,40},	// black gem
	{620,100,40,40},	// white gem
	{660,100,40,40},	// hover
	{820,140,10,100},	// player health
	{620,240,200,10},	// player deck size
	{420,140,200,668},	// hand region background
	{620,250,180,100},	// card background
	{620,350,180,100},	// card background (hover)
	{800,250,100,260},	// queue region background
	{620,450,170,170},	// alignment region background
	{0,0,1024,100},		// battle region background
	{700,100,40,40},	// good wizard static image
	{740,100,40,40},	// good wizard cast animation (1)
	{780,100,40,40},	// good wizard cast animation (2)
	{820,100,40,40},	// good wizard cast animation (3)
	{860,100,40,40},	// good wizard cast animation (4)
	{900,100,40,40},	// good wizard cast animation (5)
	{940,100,40,40},	// good wizard cast animation (6)
	{980,100,40,40},	// good wizard cast animation (7)
	{1020,100,40,40},	// good wizard cast animation (8)
	{1060,100,40,40},	// good wizard cast animation (9)
	{1100,100,40,40},	// good wizard cast animation (10)
	{1140,100,40,40},	// good wizard cast animation (11)
	{1180,100,40,40},	// good wizard cast animation (12)
	{1220,100,40,40},	// good wizard cast animation (13)
	{1260,100,40,40},	// good wizard cast animation (14)
	{1300,100,40,40},	// good wizard cast animation (15)
	{1340,100,40,40},	// good wizard cast animation (16)
	{1380,100,40,40},	// good wizard cast animation (17)
	{1420,100,40,40},	// good wizard cast animation (18)
	{830,140,30,20},	// fireball animation (1)
	{860,140,30,20},	// fireball animation (2)
	{890,140,30,20},	// fireball animation (3)
	{920,140,30,20},	// fireball animation (4)
	{950,140,30,20},	// fireball animation (5)
	{980,140,30,20},	// fireball animation (6)
	{1024,0,40,40},		// bad wizard static image
	{1024,40,40,40},	// burn animation (1)
	{1064,40,40,40},	// burn animation (2)
	{1104,40,40,40},	// burn animation (3)
	{1144,40,40,40},	// burn animation (4)
	{1184,40,40,40},	// burn animation (5)
	{1224,40,40,40},	// burn animation (6)
	{1264,40,40,40},	// burn animation (7)
	{1304,40,40,40},	// burn animation (8)
	{1344,40,40,40},	// burn animation (9)
	{1384,40,40,40},	// burn animation (10)
	{830,160,40,40},	// build up cast animation (1)
	{870,160,40,40},	// build up cast animation (2)
	{910,160,40,40},	// build up cast animation (3)
	{950,160,40,40},	// build up cast animation (4)
	{990,160,40,40},	// build up cast animation (5)
	{1030,160,40,40},	// build up cast animation (6)
	{1070,160,40,40},	// build up cast animation (7)
	{1110,160,40,40},	// build up cast animation (8)
	{1150,160,40,40},	// build up cast animation (9)
	{830,200,40,40},	// build up cast animation (10)
	{870,200,40,40},	// build up cast animation (11)
	{910,200,40,40},	// build up cast animation (12)
	{950,200,40,40},	// build up cast animation (13)
	{990,200,40,40},	// build up cast animation (14)
	{1030,200,40,40},	// build up cast animation (15)
	{1070,200,40,40},	// build up cast animation (16)
	{1110,200,40,40},	// build up cast animation (17)
	{1150,200,40,40},	// build up cast animation (18)
	{1024,80,10,10},	// hit splash animation (1)
	{1034,80,10,10},	// hit splash animation (2)
	{1044,80,10,10},	// hit splash animation (3)
	{1054,80,10,10},	// hit splash animation (4)
	{1064,80,10,10},	// hit splash animation (5)
	{1074,80,10,10},	// hit splash animation (6)
	{1084,80,10,10},	// hit splash animation (7)
	{1094,80,10,10},	// hit splash animation (8)
	{1104,80,10,10}		// hit splash animation (9)
};

/// Image ID, for use to obtain the image.
enum XYNE_IMAGE
{
	IMAGE_PUZZLE_BACKGROUND = 0,
	IMAGE_PLAYER_BACKGROUND,
	IMAGE_BLUE_GEM,
	IMAGE_RED_GEM,
	IMAGE_GREEN_GEM,
	IMAGE_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URN_ANIM_7,
	IMAGE_BURN_ANIM_8,
	IMAGE_BURN_ANIM_9,
	IMAGE_BURN_ANIM_10,
	IMAGE_BUILD_UP_ANIM_1,
	IMAGE_BUILD_UP_ANIM_2,
	IMAGE_BUILD_UP_ANIM_3,
	IMAGE_BUILD_UP_ANIM_4,
	IMAGE_BUILD_UP_ANIM_5,
	IMAGE_BUILD_UP_ANIM_6,
	IMAGE_BUILD_UP_ANIM_7,
	IMAGE_BUILD_UP_ANIM_8,
	IMAGE_BUILD_UP_ANIM_9,
	IMAGE_BUILD_UP_ANIM_10,
	IMAGE_BUILD_UP_ANIM_11,
	IMAGE_BUILD_UP_ANIM_12,
	IMAGE_BUILD_UP_ANIM_13,
	IMAGE_BUILD_UP_ANIM_14,
	IMAGE_BUILD_UP_ANIM_15,
	IMAGE_BUILD_UP_ANIM_16,
	IMAGE_BUILD_UP_ANIM_17,
	IMAGE_BUILD_UP_ANIM_18,
	IMAGE_HIT_SPLASH_ANIM_1,
	IMAGE_HIT_SPLASH_ANIM_2,
	IMAGE_HIT_SPLASH_ANIM_3,
	IMAGE_HIT_SPLASH_ANIM_4,
	IMAGE_HIT_SPLASH_ANIM_5,
	IMAGE_HIT_SPLASH_ANIM_6,
	IMAGE_HIT_SPLASH_ANIM_7,
	IMAGE_HIT_SPLASH_ANIM_8,
	IMAGE_HIT_SPLASH_ANIM_9
};

/**
* The ImageManager is responsible for the loading of image resources, scaling them when the resolution changes, and releasing them.
* 
* @author dfoelber
**/
class ImageManager
{
public:
	/**
	* Singleton accessor
	* 
	* @return Singleton instance
	**/
	static ImageManager* GetManager();
	
	/**
	* Deconstructor
	**/
	~ImageManager();
	
	/**
	* Loads images into memory
	* 
	* @param screen The screen
	**/
	void LoadImages(Screen* screen);
	
	/**
	* Gets an image
	* 
	* @param id The image ID
	* @return The surface
	**/
	Surface* GetImage( XYNE_IMAGE id );
	
	/**
	* Creates a new surface and returns it.
	* 
	* @param resolutionWidth Desired width to scale the image
	* @param resolutionHeight Desired height to scale the image
	* @param The surface
	**/
	Surface* CreateImage( int width, int height );
	
	/**
	* Gets the red build up animation.
	* 
	* @return The animation
	**/
	vector<Surface*> GetRedBuildupAnimation() { return redBuildup; }
	
private:
	/**
	* Private constructor
	**/
	ImageManager();
	
private:
	/**
	* Singleton instance
	**/
	static ImageManager* 			instance;
	
	/**
	* List of currently loaded images
	*/
	vector<Surface*>				surfaces;
	
	/**
	* The image map
	*/	
	Surface*						map;
	
	/**
	* The array containing the red build up animation
	*/
	vector<Surface*>				redBuildup;
};

#endif /*IMAGE_MANAGER_H_*/
